package com.cat.dynamicPlanning02;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/integer-break/?envType=problem-list-v2&envId=dynamic-programming
 * @create 2025/9/12 11:32
 * @since JDK17
 */

public class Solution02 {
    public int integerBreak(int n) {
        int m = (n + 1) / 2;
        int[] dp = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            dp[i] = 1;
        }
        for (int i = 2; i <= m; i++) {
            for (int j = i; j <= n; j++) {
                dp[j] = Math.max(dp[j], dp[j - i] * i);
            }
        }

        return dp[n];
    }
}
